﻿#if UNITY_EDITOR
using UnityEditor;
#endif 
using UnityEngine;
namespace SpaceDFramework
{
    /// <summary>
    /// 自定义文件打开工具
    /// </summary>
    public class FileOpenModeEditor
    {
#if UNITY_EDITOR
        [UnityEditor.Callbacks.OnOpenAssetAttribute(1)]
        public static bool ClickOnce(int instanceID, int line)
        {
            return false;
        }

        [UnityEditor.Callbacks.OnOpenAssetAttribute(2)]
        public static bool ClickTwice(int instanceID, int line)
        {
            string path = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID));
            string name = Application.dataPath + "/" + path.Replace("Assets/", "");

            if (name.EndsWith(".md"))
            { //md文件用Typora软件打开
                EditorUtil.FileOpener.OpenByExe(@"C:/Program Files/Typora/Typora.exe", name);
                return true;
            }
            return false;
        }
#endif
    }
}
